package com.mjl.shops.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mjl.shops.R;
import com.mjl.shops.base.ShopApp;
import com.mjl.shops.bean.ShopCarGoodsBean;
import com.mjl.shops.utils.StringUtils;

import java.util.List;

public class ShopCarGoodAdapter extends BaseQuickAdapter<ShopCarGoodsBean, BaseViewHolder> {

    public ShopCarGoodAdapter(int layoutResId, @Nullable List<ShopCarGoodsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShopCarGoodsBean item) {

        if (StringUtils.strEmpty(item.getmGoodsName())){
            helper.setText(R.id.goods_name_tv,item.getmGoodsName());
        }else{
            helper.setText(R.id.goods_name_tv,"");
        }

        if (item.getmGoodsSelect()>0){
            helper.setText(R.id.goods_num_tv,item.getmGoodsSelect()+"");
        }else{
            helper.setText(R.id.goods_num_tv,"0");
        }

        if (item.getmGoodsPrice()>0){
            helper.setText(R.id.goods_price_tv,"¥"+ ShopApp.decimalFormat.format(item.getmGoodsPrice()));
        }else{
            helper.setText(R.id.goods_price_tv,"¥0.00");
        }

    }
}
